#include <cstdio>

struct LNode
{
    int num;
    LNode *next;
};

LNode *head, *tail;
int n;

void init( )
{
    int i;
    head = new LNode;
    head->next = NULL;
    tail = head;
    scanf("%d", &n);
    for ( i = 1; i <= n; i++ )
    {
        LNode *s = new LNode;
        s->num = i;
        s->next = NULL;
        tail->next = s;
        tail = s;
    }
}

void work( )
{
    int i, t = 0, step = 0;
    LNode *p;
    while ( t < n - 3 )
    {
        if ( step == 1 ) step = 2;
        else step = 1;
        p = head->next;
        while ( p )
        {
            for ( i = 0; i < step - 1 && p->next; i++ )
                p = p->next;
            if ( !p->next ) break;
            p->next = p->next->next;
            p = p->next;
            t++;
        }
    }
}

void print( )
{
    int i;
    LNode *p = head->next;
    printf("%d", p->num);
    p = p->next;
    while ( p )
    {
        printf(" %d", p->num);
        p = p->next;
    }
    printf("\n");
}
 
int main( )
{
    int t;
    scanf("%d", &t);
    while ( t-- )
    {
        init( );
        work( );
        print( );
    }
    return 0;
}
